package com.ice.work.moment.ticket.controller;

import com.honeybee.cloud.framework.common.aop.Log;
import com.honeybee.cloud.framework.common.response.ResponseEntity;
import com.ice.work.moment.facade.ticket.controller.IStationController;
import com.ice.work.moment.facade.ticket.dto.StationDTO;
import com.ice.work.moment.facade.ticket.mapper.StationConvertMapper;
import com.ice.work.moment.facade.ticket.vo.StationVO;
import com.ice.work.moment.ticket.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description station
 * @Author DELL
 * @Create 2019-05-24
 * @Since 1.0.0
 */
@RestController
public class StationController implements IStationController {

    @Autowired
    private IStationService stationService;

    @Override
    @Log(name = "爬取全部车站信息")
    public ResponseEntity<Void> crawlingStation() {
        stationService.crawlingStation();
        return ResponseEntity.ok();
    }

    @Override
    @Log(name = "获取车站信息")
    public ResponseEntity<List<StationVO>> getStations() {
        List<StationDTO> dtoList = stationService.getStations();
        return ResponseEntity.ok(StationConvertMapper.INSTANCE.toVO(dtoList));
    }
}
